package Demo01;

public class Test {
    public static void main(String[] args) {
        
    }
    public static void main05(String[] args) {
        String str = new String("  ab cd ef  ");
        System.out.println(str.trim());
    }
    public static void main04(String[] args) {
        String str = new String("abcdef");
        System.out.println(str.substring(2));
        System.out.println(str.substring(0, 3));
    }
    public static void main03(String[] args) {
        String str = new String("ab&cd%ef&gh%ij");
        String[] strings = str.split("&");
        for (int i = 0; i < strings.length; i++) {
            String[] strings1 = strings[i].split("%");
            for (int j = 0; j < strings1.length; j++) {
                System.out.println(strings1[j]);
            }
        }


/*        String[] strings = str.split("&|%");
        for (int i = 0; i < strings.length; i++) {
            System.out.println(strings[i]);
        }*/
    }
    public static void main02(String[] args) {
/*        String str = new String("a b c d");
        String[] strings = str.split(" ",2);
        for (int i = 0; i < strings.length; i++) {
            System.out.println(strings[i]);
        }*/
        String str2 = new String("1\\2\\3");
        String[] strings1 = str2.split("\\\\");
        for (int i = 0; i < strings1.length; i++) {
            System.out.println(strings1[i]);
        }
    }
    public static void main01(String[] args) {
        String str = new String("abcdabcdabcd");

        System.out.println(str.replace("ab", "1234"));

        System.out.println(str.replace('a', '2'));

        System.out.println(str.replaceFirst("ab", "666"));
    }

}
